# -*- coding: utf-8 -*-
"""
@Auth:
@Time: 2022-11-04 10:38
"""
# 合并数据的脚本
import pandas as pd

import common
from pretreatment import drop_useless_features

import warnings  # 警告信息函数

warnings.filterwarnings("ignore")  # 忽略版本不同打印的警告信息


def merge_data():
    """
    合并数据集
    """
    header = True
    count = 0
    for fileName in common.FILES:
        data = pd.read_excel(common.PATH + "/" + fileName, sheet_name="Sheet1")
        print(len(data))
        count += len(data)
        # 删除无用的特征列
        data = drop_useless_features(data)
        # 以追加的方式添加入一个csv文件
        data.to_csv(common.MERGE_DATA_PATH, header=header, index=False, mode="a", encoding="utf-8")
        # 初始化后追加不再追加header
        if header:
            header = False
    print("数据总条数为：" + str(count))


if __name__ == '__main__':
    merge_data()
